package demo;

import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.logging.Logger;
import java.util.stream.Collectors;

public class Compare {
	static final Logger logger =  Logger.getLogger(App.class.getName());

	public static void main(String[] args) {
		compare();
		compare2();
		compare3();
	}

	public static List<String> compare() {
		List<String> list = Arrays.asList("a", "c", "b");

		list.sort(new Comparator<String>() {
			@Override
			public int compare(String s0, String s1) {
				return s0.compareTo(s1);
			}
		});
				
		logger.info(list.stream().collect(Collectors.joining(", ")));
		return list;
	}

	public static List<String> compare2() {
		List<String> list = Arrays.asList("a", "c", "b");

		list.sort((String s0, String s1) -> s0.compareTo(s1));
		logger.info(list.stream().collect(Collectors.joining(", ")));
		return list;
	}

	public static List<String> compare3() {
		List<String> list = Arrays.asList("a", "c", "b");

		list.sort(Comparator.<String>comparingInt(v -> v.getBytes()[0]));
		logger.info(list.stream().collect(Collectors.joining(", ")));
		return list;
	}
}
